var app = getApp()
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
Page({
  data: {
    objarr: [],
    width:0,
    height:0,
    currentTab:1,
    page: 1,
    pagesize: 10,
    totalpage: 0,//最大页数
    nomore: true,
  },
  onShareAppMessage: function (res) {
    let member_id = app.globalData.userInfo.member_id
    return {
      title: '成纪先锋微平台',
      path: '/pages/news/news_list?inviter_id=' + member_id,
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  onLoad: function (options) {
    var that = this;
    console.log(wx.getStorageSync('rd_session'))
    
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({
           width: res.windowWidth,
           height:res.windowHeight })
      }
    })

    if(options.catid){
      let par = {
        catid: options.catid,
        page:this.data.page,
        page_size:this.data.pagesize
      }
      app.ajax("news_list", par, (data, err) => {
        this.setData({
          objarr:data.data.list
        })
      })
    }
    
     
    
  },

  //滑动到底部 上拉加载
  scrollBottom: function () {
    this.data.page++
    if (this.data.page > this.data.totalpage) {
      this.setData({
        nomore: false
      })
    } else {
      let params = {
        catid: this.data.catid,
        page: this.data.page,
        page_size: this.data.pagesize
      }
      app.ajax("news_list", params, (data, err) => {
        let arr = this.data.objarr;
        for (let item of data.data.list) {
          arr.push(item);
        }
        this.setData({
          objarr: arr
        })
      })
    }

  },

  

 
  
});